package initialize

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"sale_system/user_srv/global"
)

func InitDB() {

	user := global.ServerConfig.MysqlInfo.User
	password := global.ServerConfig.MysqlInfo.Password
	host := global.ServerConfig.MysqlInfo.Host
	port := global.ServerConfig.MysqlInfo.Port
	db := global.ServerConfig.MysqlInfo.DataBase

	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local",
		user, password, host, port, db)

	global.DB, _ = gorm.Open(mysql.Open(dsn), &gorm.Config{})

}
